package com.vg.Adapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.app.Activity;
import android.app.ListActivity;
import android.content.ClipData.Item;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.SlideMenu.chatlove.R;
import com.vg.FrameUI.custom;
import com.vg.classSample.Friend;

public class adapter_Friend extends BaseAdapter {

	private ImageView icon;
	private Button bt_name;
	private TextView tv_status;
	
	private Context context;

	private Activity activity;
	//private ArrayList<HashMap<String, String>> data=new ArrayList<HashMap<String,String>>();
	private static LayoutInflater inflater = null;

	// Friend m_Friend=new Friend(status, name, url_img)

	private ArrayList<Friend> mItems=new ArrayList<Friend>();
		 
		public adapter_Friend(Context context, ArrayList<Friend> items) {
			this.context = context;
		     mItems = items;
		     String service=Context.LAYOUT_INFLATER_SERVICE;
		     inflater=(LayoutInflater)context.getSystemService(service);
		}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mItems.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		//View vi = convertView;
		if (convertView == null) {
			// convertView =
			// LayoutInflater.from(getContext()).inflate(R.layout.item_contact,
			// null);
			convertView = inflater.inflate(R.layout.item_contact, null);
		}
		custom post = (custom) convertView.findViewById(R.id.frame_friend_item);
		post.fillData(mItems.get(position).getName(), mItems.get(position).getUrl_img());
	//	post.fillData(mItems.get(position).getUrl_img(), mItems.get(position).getName(), mItems.get(position).getStatus());
		// if (getItem(position).getImage() != null) {
		// icon.setImageBitmap(getItem(position).getImage());
		// } else {
		// icon.setImageResource(R.drawable.ic_launcher);
		// getItem(position).loadImage();
		// }
		bt_name = (Button) convertView.findViewById(R.id.contact_tv_name_1);
		tv_status = (TextView) convertView
				.findViewById(R.id.contact_tv_status_1);
//		//ArrayList<Friend> id=new ArrayList<Friend>();
//		//id=mItems.
//
		 bt_name.setText(mItems.get(position).getName());
		 tv_status.setText(mItems.get(position).getStatus());
//		 mItems.get(position).loadImage();
//		 String Name_test=mItems.get(position).get
		 
//		 if(id.get(position).getImage()!= null)
//		 {
//			icon.setImageBitmap(id.get(position).getImage());
//		 }
//		 else
//		 {
//			 icon.setImageResource(R.drawable.ic_launcher);
//			 id.get(position).loadImage();
//		 }

		return convertView;

	}

	

}
